import datetime

from rest_framework import serializers
from order import models

class CouponSer(serializers.ModelSerializer):
    class Meta:
        model = models.Coupon
        fields = '__all__'

class UserCoupon(serializers.ModelSerializer):
    coulist=serializers.SerializerMethodField(read_only=True)
    def get_coulist(self,obj):
        return {"id":obj.coupon.id,"condition":obj.coupon.condition,"name":obj.coupon.name,"start_time":obj.coupon.start_time,'end_time':obj.coupon.end_time,
                'price':obj.coupon.price}
    class Meta:
        model = models.UserCoupon
        fields = '__all__'

class OrderCoupon(serializers.ModelSerializer):
    class Meta:
        model = models.OrderModel
        fields = '__all__'

class OrderDetail(serializers.ModelSerializer):
    class Meta:
        model = models.OrderDetailModel
        fields = '__all__'

